using DocumentaWeb.Core;
using DocumentaWeb.Core.Mappers;
using DocumentaWeb.Core.Messages;
using MbUnit.Framework;
using Rhino.Mocks;

namespace DocumentaWeb.Tests.Unit.Mappers
{
	[TestFixture, FixtureCategory("Mappers")]
	public class ContratistaMapperTestFixture
	{
		private MockRepository mockery;
		private AddContratistaRequestDto request;
		private IContratistaMapper mapper;


		[SetUp]
		public void SetUp()
		{
			mockery=new MockRepository();
			request = mockery.DynamicMock<AddContratistaRequestDto>();
			mapper = new ContratistaMapper();
		}

		[Test]
		public void Should_Map_From_AddContratistaRequestDto()
		{
			using(mockery.Record())
			{
				SetupResult.For(request.RazonSocial).Return("Contratista Prueba");
				SetupResult.For(request.Cuit).Return("20-24479079-9");
				SetupResult.For(request.Web).Return("http://127.0.0.1");
				SetupResult.For(request.Domicilio1).Return("San Luis 1188");
				SetupResult.For(request.Domicilio2).Return("4to C");
			}

			IContratista contratista;

			using(mockery.Playback())
			{
				contratista = mapper.MapFrom(request);
			}

			Assert.AreEqual(contratista.RazonSocial,"Contratista Prueba","Razon Social diferente");
			Assert.AreEqual(contratista.Cuit,"20-24479079-9","El cuit es diferente");
			Assert.AreEqual(contratista.Web,"http://127.0.0.1","la web es diferente");
			Assert.AreEqual(contratista.Domicilio.Direccion1,"San Luis 1188","la direccion1 no es correcta");
			Assert.AreEqual(contratista.Domicilio.Direccion2,"4to C","la direccion2 no es correcta");
		}


	}
}